package cn.juque.jdfsystem.console.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author juque
 * @version 1.0.0
 * <ul>
 *     <li>FileInfoController</li>
 * </ul>
 * @date 2023-01-20 09:07:00
 **/
@Slf4j
@Controller
@RequestMapping("/jdf/file")
public class FileInfoController extends BaseController {

    /**
     * 上传
     *
     * @throws IOException IOException
     */
    @PostMapping(value = "/upload")
    @ResponseBody
    public void upload(HttpServletResponse response) throws IOException {
        response.sendRedirect(super.createUrlPath("/jdf/file/upload"));
    }

    /**
     * 查看图片
     *
     * @param id 主键
     */
    @GetMapping(value = "/view/{id}")
    public void view(@PathVariable String id, Boolean ignore, HttpServletResponse response) throws IOException {
        String relativePath = "/jdf/file/view/" + id + "?ignore = " + ignore;
        response.sendRedirect(super.createUrlPath(relativePath));
    }
}
